<template>
	<view class="sales-list">
		
		
		<!-- <view class="con-3 ">
			<view class="con-3_left ">{{itemChooselist.venue_name}}</view>
			<view class="con-3_right " @click="show = true">切换</view>
		</view> -->
		<view class="con-1">
			<nav-bar title="销售排行" color="white" bg="rgba(0,0,0,0)"></nav-bar>
			<view class="bg">
				<view class="address">
					<view class="flex-space-between">
						<view class="flex-align">
							<van-image v-if="itemChooselist.venue_thumb != ''" width="74rpx" height="74rpx" radius="2" style="margin-right: 10rpx;" :src="itemChooselist.venue_thumb"/>
							<van-image v-else width="74rpx" height="74rpx" radius="10rpx" fit="cover" style="margin-right: 10rpx;" src="https://img.yzcdn.cn/vant/cat.jpeg" />
							<view>
								<view class="address-name">{{itemChooselist.venue_name}}</view>
								<view class="address-desc">地址:{{itemChooselist.address}}</view>
							</view>
						</view>
						<view class="exchange flex-center flex-column " @click="show = true">
							<van-icon name="exchange" size="16" />
							切换
						</view>
					</view>
				</view>
			</view>
		
		</view>
		<view style="width: 100%; height: 60rpx;background-color: #f8f8f8;position: fixed;top: 300rpx;z-index: 9;">
			<view style="float: left;">
				<image style="width: 32rpx;height: 32rpx;margin-top: 15rpx;margin-left: 30rpx;" src="https://jiangsudiantuo2022.oss-cn-hangzhou.aliyuncs.com/img/dbe7a7371520f7585b4a83558336c24acbace2cc.png" mode=""></image>
			</view>
			<view style="float: left;line-height: 60rpx;font-size: 28rpx;color: #aaaaaa;margin-left: 20rpx;">
				数据仅供参考，以后台财务数据为准
			</view>
		</view>
		<view class="dateslist">
			<van-row class="dates text-center">
				<van-col v-for="item in dates" :key="item.panel" :span="12" >
					<view class="date-item" :class="{ active: dateActive === item.panel }" @click="dataslist(item)">
						{{ item.label }}
					</view>
				</van-col>
			</van-row>
		</view>
		<view class="dateslists">
			<van-row class="dates text-center">
				<van-col v-for="item in datelist" :key="item.value" :span="6" >
					<view class="date-item" :class="{ active: dateActives === item.value }" @click="dataslists(item)">
						{{ item.label }}
					</view>
				</van-col>
			</van-row>
		</view>
<!-- 		<van-tabs :active="tabActive" sticky title-active-color="#333" title-inactive-color="rgb(167,167,167)" color="rgb(143,139,232)" line-width="30"  @change="onChange">
		    <van-tab title="运动力排行"></van-tab>
		    <van-tab title="购买力排行"></van-tab>
		</van-tabs> -->
		
		<view class="module1">
			
			<view class="list">
				<view v-for="(item, index) in list" :key="index" class="item flex-space-between">
					<view class="flex-align">
						<view class="index">
							<!-- <view class="crown flex-center align-end" :style="{ '--bg': `url(${crowns[index]}) left top/100% 100% no-repeat` }" v-if="index < 0">{{ index + 1 }}</view> -->
							<!-- <view v-else>NO.{{ index + 1 }}</view> -->
							<view v-if="index > 2 ">NO.{{ index + 1 }}</view>
							<view  v-if="index == 0 " style="margin-left: 10rpx;">
								<image style="width:45rpx ; height: 36rpx;"  src="https://jiangsudiantuo2022.oss-cn-hangzhou.aliyuncs.com/img/d5ecde4d1fe6b1aff010de7b51d0e295c864d8f9.png" mode=""></image>
								
							</view>
							<view  v-if="index == 1 " style="margin-left: 10rpx;">
								<image style="width:45rpx ; height: 36rpx;" src="https://jiangsudiantuo2022.oss-cn-hangzhou.aliyuncs.com/img/cefcff4298ec0ade4093302f208ccff31be200b9.png" mode=""></image>
							
							</view>
							<view  v-if="index == 2 " style="margin-left: 10rpx;">
								<image style="width:45rpx ; height: 36rpx;"  src="https://jiangsudiantuo2022.oss-cn-hangzhou.aliyuncs.com/img/933c90dda5ac0e26f08a76f2364399ee488eae5b.png" mode=""></image>
					
							</view>
						</view>
						<!-- <view class="img">
							<van-image width="50rpx" height="50rpx" radius="10rpx" fit="cover"
								src="https://img.yzcdn.cn/vant/cat.jpeg" />
						</view> -->
					</view>
					<view class="" style="position: absolute;left: 25%;">
						<view class="name" style="align-items: stretch ">{{ item.username }}</view>
						<view class="name">{{ item.phone }}</view>
					</view>
					<view class="flex-align">
						<!-- <view class="type">{{  panel_s == 1 ? '消费总额' : '购买次数' }}</view> -->
						<!-- <view class="value">{{ panel_s == 1 ? '￥' : '' }}{{ item.order_num }}</view> -->
						<view class="type"  v-if="panel_s == 1">总额</view>
						<view class="value"  v-if="panel_s == 2">{{ item.order_num }}</view>
						<view class="value" v-if="panel_s == 1">￥{{ item.order_num }}</view>
						<view class="type" v-if="panel_s == 2">次</view>
					</view>
				</view>
			</view>
		</view>
		<van-popup closeable :show="show" round position="bottom" @close="show = false">
			<view class="good-box">
				<view class="title">
					切换场馆
				</view>
				<view class="good-list">
					<!-- <van-radio-group :value="radio" @change="onChange"> -->
						<view class="good-item" v-for="(item,index) in venuelist" :key="index" @click="onChangelist(item)">
							<!-- <van-radio :name="index" :value="index" color="#2f75fa" :checked="index == 0 ? true : false"> -->
								<view class="flex-align">
									<van-image width="124rpx" height="124rpx" radius="10rpx" fit="cover"
										v-if="item.venue_thumb != ''" :src="item.venue_thumb" />
									<van-image v-else width="124rpx" height="124rpx" radius="10rpx" fit="cover"
										src="https://img.yzcdn.cn/vant/cat.jpeg" />
									<view class="info">
										<view class="name">{{item.venue_name}}</view>
										<view class="flex-align" v-if="item.project_list != ''">
											<view class="tag" v-if="item.project_list[0].name != ''">{{item.project_list[0].name}}</view>
											<view class="tag" v-if="item.project_list[1].name != '' && item.project_list[1]">
												{{item.project_list[1].name}}
											</view>
											<view class="tag" v-if="item.project_list[2].name != ''&& item.project_list[2]">
												{{item.project_list[2].name}}
											</view>
										</view>
										<view class="address">{{item.address}}</view>
									</view>
								</view>
							<!-- </van-radio> -->
						</view>
					<!-- </van-radio-group> -->
				</view>
		
				<!-- <view class="footer">
					<view class="btn" @click="queren">确认</view>
				</view> -->
			</view>
		</van-popup>
	</view>
</template>

<script>
	const personal = require("@/api/personal/index.js");
export default {
	data() {
		const { assetsPath } = this.$https;
		const crowns = [
			assetsPath + 'a37e699386b6774929e5371be458b1c0820c82e8.png',
			assetsPath + 'd0c50a90aa7f19ce225cfea12214f32ba5f5b03b.png',
			assetsPath + '56c64dcdf2ee4c1a127d95e85d533711c400e9e4.png',
		];
		
		return {
			assetsPath,
			tabActive: 1,
			datelist: [
				{ label: '周榜', value: '6' },
				{ label: '月榜', value: '7' },
				{ label: '年榜', value: '8' },
				{ label: '总榜', value: '9' },
			],
			dateActives: '6',
			dates: [
				{ label: '运动力排行', panel: '2' },
				{ label: '购买力排行', panel: '1' },
			],
			dateActive: '2',
			list: [
				{ name: '123', value: 8124 },
				{ name: '123', value: 8124 },
			],
			// crowns,
			show: false,
			venuelist:[],//场馆列表
			itemChooselist:{}, // 场馆数据
			itemChoose:{},
			nac:'',
			panel_s:"",
			listQuery: { //分页
				pageNo: 1,
				pageSize: 10,
			},
			totalPage: '', //几页
		}
	},
	onLoad() {
		if (uni.getStorageSync("entry_name") == '') {
			uni.showToast({
				title: '请登录！',
				icon:'exception',
				duration:850
			});
			setTimeout(() => {
				uni.navigateTo({
					url:'/pages/my-center/my-center'
				})
			}, 1000);
		} 
		var data = uni.getStorageSync("wqzdy" );
		var items = JSON.parse(data)
		this.venuelist = items
		this.itemChooselist = this.venuelist[0]
		this.panel_s = '2'
		this.nac = '6'
		this.member()
	},
	methods: {
		async member() {
			let that = this;
			if (this.listQuery.pageNo === 1) that.list = [];
			// uni.showLoading({
			// 	title: "加载中",
			// 	mask: true,
			// });
			let params = {
				venue_id: this.itemChooselist.id,
				sourceTab: this.nac,
				panel: this.panel_s,
				page: this.listQuery.pageNo,
				pageSize: this.listQuery.pageSize,
			};
			let res = await personal.member(params);
			if (res.code == 1) {
				that.list = that.list.concat( res.data.list.data); //将数据拼接在一起
				that.totalPage = res.data.list.last_page
				// uni.hideLoading();
			}
		},
		onReachBottom() {
			// uni.showLoading({
			// 	title: '加载中'
			// });
			if (this.totalPage <= this.listQuery.pageNo) {
				// uni.hideLoading();
				uni.showToast({
					title: '没有更多了',
					duration: 2000,
					icon: 'none'
				});
				return
			}
			this.listQuery.pageNo += 1;
			this.member()
		},
		dataslist(item) {
			this.listQuery.pageNo = 1
			this.list =[]
			this.panel_s = ''
			this.dateActive = item.panel
			this.panel_s = item.panel
			this.member()
		},
		dataslists(item) {
			this.nac = ''
			this.listQuery.pageNo = 1
			this.list =[]
			this.dateActives = item.value
			this.nac = item.value
			this.member()
		},
		// onChange({ detail: { index } }) {
		// 	this.tabActive = index;
		// },
		// 选择场馆
		onChange(e) {
			let that = this
			let i = e.detail
			const item = this.venuelist[i]
			if(item) {
				this.itemChoose = item
				this.venuelist[i].checked = true
			} else {
				this.itemChoose = {}
			}
		},
		onChangelist(item){
			this.itemChoose = item
			this.listQuery.pageNo = 1
			this.list =[]
			this.itemChooselist = this.itemChoose
			this.show = false
			this.dateActive = '6'
			this.nac = '6'
			this.panel_s = '2'
			this.dateActives = '2'
			this.member()
		},
		// 确认按钮
		queren(){
			this.listQuery.pageNo = 1
			this.list =[]
			this.itemChooselist = this.itemChoose
			this.show = false
			this.dateActive = '6'
			this.nac = '6'
			this.panel_s = '2'
			this.dateActives = '2'
			this.member()
		},
	}
}
</script>

<style lang="scss" scoped>
.sales-list {
	// padding-bottom: 40rpx;
	width: 100%;
	height: 100%;
	display: flex;
	flex-direction: column;
	background-color: rgb(243, 243, 243);
	
	.con-1 {
		width: 100%;
		position: relative;
		z-index: 999;
	
		/deep/ .nav-bar {
			position: fixed;
			z-index: 999;
		}
	
		.bg {
			width: 100%;
			height: 300rpx;
			background-image: url("https://jiangsudiantuo2022.oss-cn-hangzhou.aliyuncs.com/img/5d1ccc3b7ac6cc185130c88a8ac2e90b1eeba707.png");
			background-size: 100%;
			background-position: 50% 80%;
			position: fixed;
	
			.address {
				color: #fff;
				padding-top: 190rpx;
				padding-right: 30rpx;
				padding-left: 30rpx;
				height: 150rpx;
	
				&-name {
					font-size: 34rpx;
					font-weight: 700;
					line-height: 34rpx;
				}
	
				&-desc {
					margin-top: 18rpx;
					font-size: 22rpx;
					line-height: 22rpx;
				}
	
				.exchange {
					width: 100rpx;
					height: 100rpx;
					border-radius: 50%;
					background-color: rgba(0, 0, 0, 0.2);
					color: rgb(234, 248, 248);
					font-size: 24rpx;
				}
			}
		}
	}
	
	/deep/ .good-box {
		height: 60vh;
		padding: 0px 30rpx;
		display: flex;
		flex-direction: column;
		
		.title {
			color: #000;
			font-size: 30rpx;
			font-weight: 700;
			margin-top: 40rpx;
		}
		.van-radio__label {
			line-height: inherit;
		}
	
		.good-list {
			flex: 1;
			height: 0;
			overflow: auto;
	
			.good-item {
				margin-top: 30rpx;
	
				.info {
					margin-left: 25rpx;
					.address {
						color: #fff;
						padding-top: 20rpx;
						padding-right: 30rpx;
						height: 70rpx;
					
						&-name {
							font-size: 34rpx;
							font-weight: 700;
							line-height: 34rpx;
						}
					
						&-desc {
							margin-top: 18rpx;
							font-size: 22rpx;
							line-height: 22rpx;
						}
					
						.exchange {
							width: 100rpx;
							height: 100rpx;
							border-radius: 50%;
							background-color: rgba(0, 0, 0, 0.2);
							color: rgb(234, 248, 248);
							font-size: 24rpx;
						}
					}
					
					.name {
						color: rgb(51, 51, 51);
						font-size: 30rpx;
						font-weight: 500;
						margin-bottom: 10rpx;
					}
	
	
					.tag {
						color: rgb(4, 179, 90);
						font-size: 24rpx;
						font-weight: 500;
						padding: 0px 10rpx;
						margin-right: 20rpx;
						background-color: rgba(4, 179, 90, 0.2);
						border-radius: 4rpx;
	
						&:nth-of-type(2) {
							color: rgb(236, 70, 246);
							background-color: rgba(236, 70, 246, 0.2);
						}
					}
	
					.address {
						margin-top: 10rpx;
						color: rgb(136, 136, 136);
						font-size: 22rpx;
					}
				}
	
			}
		}
	
		.footer {
			padding: 20rpx 0;
			background-color: rgb(255, 255, 255);
	
			.btn {
				color: rgb(255, 255, 255);
				font-size: 30rpx;
				font-weight: 700;
				padding: 20rpx 0;
				text-align: center;
				background-image: linear-gradient(0deg, rgb(99, 93, 247) 0%, rgb(165, 173, 246) 100%);
				border-radius: 60rpx;
			}
		}
	}
	.con-3 {
		position: fixed;
		width: 100%;
		height: 80rpx;
		background-color: #f8f8f8;
		color: rgb(51, 51, 51);
		font-size: 28rpx;
		font-weight: 700;
		z-index: 9;
		top: 0;
	
		.con-3_left {
			float: left;
			line-height: 80rpx;
			margin-left: 29rpx;
		}
	
		.con-3_right {
			float: right;
			line-height: 80rpx;
			color: rgb(90, 101, 255);
			margin-right: 29rpx;
		}
	}
	.dateslist{
		position: fixed;
		z-index: 9;
		top: 360rpx;
		width: 100%;
		height: 100rpx;
		background-color: #ffffff;
		line-height: 100rpx;
		
		.dates {
			// padding: 0 30rpx;
			// margin-top: 80rpx;
			color: rgb(180, 180, 180);
			font-size: 28rpx;
			
			
			.date-item {
				// padding: 30rpx 0;
				font-weight: 700;
			}
			
			.active {
				// color: rgb(51,51,51);
				color: #000
			}
		}
	}
	
	.dateslists{
		position: fixed;
		z-index: 9;
		top: 460rpx;
		width: 100%;
		height: 100rpx;
		background-color: #ffffff;
		line-height: 100rpx;
		
		.dates {
			// padding: 0 30rpx;
			// margin-top: 80rpx;
			color: rgb(180, 180, 180);
			font-size: 28rpx;
			
			
			.date-item {
				// padding: 30rpx 0;
				font-weight: 700;
			}
			
			.active {
				color: #000
			}
		}
	}
	
	.module1 {
		padding: 0 30rpx;
		margin-top: 560rpx;
		
		.list {
			flex: 1;
			padding: 0rpx 30rpx;
			// overflow-y: auto;
			.item {
				height: 120rpx;
				
				& + .item {
					border-top: 1rpx solid rgb(229,229,229);
				}
				
				&:nth-of-type(-n + 3) {
					.crown {
						color: rgb(255,255,255);
						font-size: 20rpx;
						width: 45rpx;
						height: 36rpx;
						background: var(--bg);
						line-height: 1.05;
					}
				}
				
				.index {
					width: 120rpx;
					font-size: 30rpx;
					font-weight: 700;
				}
				
				.img {
					margin-right: 40rpx;
				}
				
				.name {
					font-size: 30rpx;
					font-weight: 700;
					white-space: pre-line;
				}
				
				.type {
					font-size: 26rpx;
					margin-right: 10rpx;
				}
				
				.value {
					font-size: 24rpx;
					font-family: DIN;
					font-weight: 700;
				}
			}
		}
	}
	
	
}
</style>
